<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8">
    <title>JSDoc: Source: PlotWindow.js</title>
    
    <script src="scripts/prettify/prettify.js"> </script>
    <script src="scripts/prettify/lang-css.js"> </script>
    <!--[if lt IE 9]>
      <script src="//html5shiv.googlecode.com/svn/trunk/html5.js"></script>
    <![endif]-->
    <link type="text/css" rel="stylesheet" href="styles/prettify-tomorrow.css">
    <link type="text/css" rel="stylesheet" href="styles/jsdoc-default.css">
</head>

<body>

<div id="main">
    
    <h1 class="page-title">Source: PlotWindow.js</h1>
    
    


    
    <section>
        <article>
            <pre class="prettyprint source"><code>// PlotWindow.js

/**
 * @fileOverview a file to define DiagnosticsPlotWindow class.
 * @author Ryohei Ueda
 */

ROSLIB.DiagnosticsPlotWindow = function(spec) {
  var self = this;
  self.directory = spec.directory;
};

ROSLIB.DiagnosticsPlotWindow.prototype.getDirectory = function() {
  var self = this;
  return self.directory;
};

ROSLIB.DiagnosticsPlotWindow.prototype.initializePlotter = function() {
  var self = this;
  self.plotter.initializePlot(self.$html.find('.plot-window-inner'), {
    margin: {
      left: 20,
      top: 2,
      bottom: 20,
      right: 2
    },
    yaxis: {
      auto_scale: true,
      auto_scale_margin: 0.2,
      min: 0.1,
      tick: 3
    }
  });
  self.plotter.clearData();
};


ROSLIB.DiagnosticsPlotWindow.prototype.initialize = function(spec) {
  var self = this;
  self.index = spec.index;
  self.plotter = new ROSLIB.RWTPlot({
    max_data: 10,
    timestamp: true
  });
  
  // creating html
  self.$html = $('&lt;div class="rwt-diagnostics-plot-window col-xs-2">&lt;/div>');
  self.$html.data('index', self.index);
  self.$html.append('&lt;div class="background">&lt;p>' + self.directory.status.name +'&lt;/p>&lt;/div>');
  self.$html.append('&lt;div class="plot-window-inner" id="rwt-plot-window-' + self.index + '">&lt;/div>');
  self.$html.append('&lt;button class="close-button-layer close" type="button">&times;&lt;/button>');
  self.$html.find('.close').click(function() {
    self.remove();
  });
};

ROSLIB.DiagnosticsPlotWindow.prototype.getHTMLObject = function() {
  var self = this;
  return self.$html;
};

ROSLIB.DiagnosticsPlotWindow.prototype.update = function(data) {
  var self = this;
  var now = ROSLIB.Time.now();
  self.plotter.addData(now, [Number(data)]);
  if (self.directory.status.isOK()) {
    self.plotter.setColor(d3.rgb('#5cb85c'));
  }
  else if (self.directory.status.isWARN()) {
    self.plotter.setColor(d3.rgb('#f0ad4e'));
  }
  else if (self.directory.status.isERROR()) {
    self.plotter.setColor(d3.rgb('#d9534f'));
  }
};

ROSLIB.DiagnosticsPlotWindow.prototype.remove = function() {
  var self = this;
  self.$html.remove();
  self.$html = null;
};

</code></pre>
        </article>
    </section>




</div>

<nav>
    <h2><a href="index.html">Index</a></h2><h3>Classes</h3><ul><li><a href="DiagnosticsDirectory.html">DiagnosticsDirectory</a></li><li><a href="DiagnosticsHistory.html">DiagnosticsHistory</a></li><li><a href="DiagnosticsStatus.html">DiagnosticsStatus</a></li><li><a href="RWTRobotMonitor.html">RWTRobotMonitor</a></li></ul>
</nav>

<br clear="both">

<footer>
    Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.2.2</a> on Thu Jan 23 2014 03:55:54 GMT+0900 (JST)
</footer>

<script> prettyPrint(); </script>
<script src="scripts/linenumber.js"> </script>
</body>
</html>
